<?php

/*
 *  This file is part of Urd.
 *
 *  Urd is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *  Urd is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. See the file "COPYING". If it does not
 *  exist, see <http://www.gnu.org/licenses/>.
 *
 * $LastChangedDate: 2008-06-24 08:30:17 +0200 (Tue, 24 Jun 2008) $
 * $Rev: 1222 $
 * $Author: styck $
 * $Id: smarty.php 1222 2008-06-24 06:30:17Z styck $
 */
if (!defined('ORIGINAL_PAGE')) die('This file cannot be accessed directly.');

// This page handles the including of the right smarty template.
// Language 'templates' are added as well (although not quite smarty.)

$pathsm = realpath(dirname(__FILE__));

require_once '../smarty_config.php';
require_once "$smarty_path";
require_once 'web_functions.php';
require_once 'urdversion.php';
require_once 'defines.php';

$smarty = new Smarty();

if (isset($userID)) {
	$template = select_template($db, $userID);
	$lang = select_language($db, $userID);
} else {
    $lang = select_language($db, NULL);
    $template = select_template($db, NULL);
}
if ($template === NULL)
	$template = DEFAULT_TEMPLATE;

$tpldir = '../html/smarty/templates/';
$langdir = '../functions/lang/';

function get_menu_display()
{
	if (!isset($_SESSION['menudisplay'])) $_SESSION['menudisplay'] = 1;
	return $_SESSION['menudisplay'];
}

$smarty->assign('TPLDIR', $tpldir . $template) ;
$smarty->assign('IMGDIR', '../html/smarty/templates/' . $template . '/img');
$smarty->assign('VERSION', get_version());
$smarty->assign('show_menu', get_menu_display());
$smarty->template_dir = "$pathsm/../html/smarty/templates/" . $template;
$smarty->compile_dir = "$pathsm/../html/smarty/c_templates/" . $template;
$smarty->cache_dir = "$pathsm/../html/smarty/cache";
$smarty->config_dir = "$pathsm/../html/smarty/configs";
$smarty->caching = 0; // Caching doesn't work for some pages (like Browse Sets)

load_language($lang);

?>
